package org.itzheng.yuezhi.utils;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager;

import org.itzheng.yuezhi.App;

/**
 * Title:<br>
 * Description: <br>
 * Company: <br>
 *
 * @author ZhengYongdong
 * @email ItZheng@ZoHo.com
 * @date 2016/6/25 0025
 */
public class MyGlide {
    private static RequestManager requestManager;

    public MyGlide() {
        if (requestManager == null) {
            requestManager = Glide.with(App.application);
        }
    }

    public static MyGlide getInstance() {
        return new MyGlide();
    }

    public void setImage(int res, ImageView imageView) {
        requestManager.
                load(res).into(imageView);
    }

    public void setImage(String url, ImageView imageView) {
        setImage(url, imageView, 0);
    }

    public void setImage(String url, ImageView imageView, int defaultImages) {
        requestManager
                .load(url)
                .centerCrop()
                .placeholder(defaultImages)
                .crossFade()
                .into(imageView);
    }


}
